package com.bristua.barcode.supplier.biz;

import com.bristua.barcode.customer.dao.TCustomerBindSupplierMapper;
import com.bristua.barcode.customer.model.TCustomerBindSupplier;
import com.bristua.barcode.customer.model.condition.TCustomerBindSupplierExample;
import com.bristua.barcode.supplier.dao.TQrCodeMapper;
import com.bristua.barcode.supplier.model.TQrCode;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/8/30.
 */
@Service
@Transactional
public class UnBindSupplierQRCodeBiz {//解绑
    @Resource
    private TCustomerBindSupplierMapper tCustomerBindSupplierMapper;

    @Resource
    private TQrCodeMapper tQrCodeMapper;

    public void unBindSupplierQRcode(String supplierId,String qrCodeId){
        TCustomerBindSupplierExample tCustomerBindSupplierExample = new TCustomerBindSupplierExample();
        tCustomerBindSupplierExample.createCriteria().andSupplierIdEqualTo(supplierId).andQrCodeIdEqualTo(qrCodeId);
        tCustomerBindSupplierMapper.deleteByExample(tCustomerBindSupplierExample);
        TQrCode tQrCode = new TQrCode();
        tQrCode.setQrCodeId(qrCodeId);
        tQrCode.setIsBind(0);
        tQrCodeMapper.updateByPrimaryKeySelective(tQrCode);
    }
}
